//
//  RootViewController.swift
//  TravelNotes
//
//  Created by 千锋 on 16/8/15.
//  Copyright © 2016年 胡光健. All rights reserved.
//

import UIKit

class RootViewController: UIViewController {
    
    var titleLabel: UILabel?
    var leftButton: UIButton?
    var rightBuuton: UIButton?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.whiteColor()
        self.navigationController?.navigationBar.translucent = false
         self.navigationController?.navigationBar.barTintColor = UIColor.RGBA(85, 164, 154)
        
        titleLabel = Factory.createLabelWith(CGRectMake(0, 0, 100, 44), text: "", font: UIFont.systemFontOfSize(20), textAlignment: NSTextAlignment.Center, textColor: UIColor.whiteColor())
        self.navigationItem.titleView = titleLabel
        
        
        leftButton = Factory.createButtonWith(CGRectMake(0, 0, 44, 44), type: UIButtonType.Custom, title: "", titleColor: UIColor.whiteColor(), target: nil, imageName: "", action: "", backgroundImageName: "")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: self.leftButton!)
        
        rightBuuton = Factory.createButtonWith(CGRectMake(0, 0, 44, 44), type: UIButtonType.Custom, title: "", titleColor: UIColor.whiteColor(), target: nil, imageName: "", action: "", backgroundImageName: "")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: self.rightBuuton!)
    }
    
    func addLeftTarget(selector: Selector) {
        self.leftButton?.addTarget(self, action: selector, forControlEvents: UIControlEvents.TouchUpInside)
    }
    
    func addRightTarget(selector: Selector) {
        self.rightBuuton?.addTarget(self, action: selector, forControlEvents: .TouchUpInside)
    }
}
